package com.剑指offer;

public class _2替换空格
{
    public static void main(String[] args)
    {
        System.out.println("2多了一个输出");
        System.out.println(replaceSpace("we are happy"));
    }

    public static String replaceSpace(String s)
    {
        while (s.contains(" "))
        {
            int index = s.indexOf(" ");
            s = s.substring(0, index) + "%20" + s.substring(index + 1);
        }
        return s;
    }
}
